import {patch} from '../../vdom/patch'
import {Watcher} from '../../observe/Watcher'
export function mountComponent(vm) {
  const updateComponent = () => {
    vm._update(vm._render())
  }
  new Watcher(vm, updateComponent, ()=>{
  })
}
export function lifeCycleMixin(Vue) {
  Vue.prototype._update = function (vnode) {


    const vm = this
    let preVnode = vm._preVnode
    vm._preVnode = vnode

    if(!preVnode){
      vm.$el = patch(vm.$el, vnode)
    }else{
      vm.$el = patch(preVnode, vnode)
    }


  }
}
export function callHook (vm, hook) {
  const handlers = vm.$options[hook]
  if (handlers) {
    for (let i = 0, j = handlers.length; i < j; i++) {
      handlers[i].call(vm)
    }
  }
}
